import UIKit
// 我是main分支的代码
class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        //我是用户2提交了
         //我是用户2第二次提交了
         //我是用户2第三次提交 
         //我是用户1第四次提交
         //我是用户1第五次提交
         //我是用户2第四次提交 
         //我是用户2第x提交
        // 设置背景颜色
        // 我想修改下文件，结果我改到dev2上，实际我应该修改在dev1上
        view.backgroundColor = .systemBackground
        // 我是main 上的修改
        // 创建欢迎标签
        let welcomeLabel = UILabel()
        welcomeLabel.text = "欢迎使用我的iOS应用！"
        welcomeLabel.font = UIFont.systemFont(ofSize: 24, weight: .bold)
        welcomeLabel.textAlignment = .center
        welcomeLabel.textColor = .label
        welcomeLabel.translatesAutoresizingMaskIntoConstraints = false
        // 用户1也来提交一点
        // 创建描述标签
        let descriptionLabel = UILabel()
        descriptionLabel.text = "这是一个用Swift开发的iOS应用"
        descriptionLabel.font = UIFont.systemFont(ofSize: 16)
        descriptionLabel.textAlignment = .center
        descriptionLabel.textColor = .secondaryLabel
        descriptionLabel.translatesAutoresizingMaskIntoConstraints = false
        
        // 创建按钮
        // 测试rebase1
 // 测试rebase2
        let actionButton = UIButton(type: .system)
        actionButton.setTitle("点击我", for: .normal)
        actionButton.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .medium)
        actionButton.backgroundColor = .systemBlue
        actionButton.setTitleColor(.white, for: .normal)
        actionButton.layer.cornerRadius = 8
        actionButton.translatesAutoresizingMaskIntoConstraints = false
        actionButton.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
        
        // 添加到视图
        view.addSubview(welcomeLabel)
        view.addSubview(descriptionLabel)
        view.addSubview(actionButton)
        
        // 设置约束
        NSLayoutConstraint.activate([
            // 欢迎标签约束
            welcomeLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor),
            welcomeLabel.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: -60),
            welcomeLabel.leadingAnchor.constraint(greaterThanOrEqualTo: view.leadingAnchor, constant: 20),
            welcomeLabel.trailingAnchor.constraint(lessThanOrEqualTo: view.trailingAnchor, constant: -20),
            
            // 描述标签约束
            descriptionLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor),
            descriptionLabel.topAnchor.constraint(equalTo: welcomeLabel.bottomAnchor, constant: 16),
            descriptionLabel.leadingAnchor.constraint(greaterThanOrEqualTo: view.leadingAnchor, constant: 20),
            descriptionLabel.trailingAnchor.constraint(lessThanOrEqualTo: view.trailingAnchor, constant: -20),
            
            // 按钮约束
            actionButton.centerXAnchor.constraint(equalTo: view.centerXAnchor),
            actionButton.topAnchor.constraint(equalTo: descriptionLabel.bottomAnchor, constant: 32),
            actionButton.widthAnchor.constraint(equalToConstant: 120),
            actionButton.heightAnchor.constraint(equalToConstant: 44)
        ])
    }
    
    @objc private func buttonTapped() {
        let alert = UIAlertController(title: "你好！", message: "欢迎来到Swift iOS开发世界！", preferredStyle: .alert)
        alert.addAction(UIAlertAction(title: "好的", style: .default))
        present(alert, animated: true)
    }
} 